package com.zn.net
{

    /**
     *Remoting连接
     * @author zn
     *
     */
    public class RemotingNet extends NetConn
    {
        protected static var _instance:RemotingNet;

        public static var SERVER_NAME:String = "";

        public function RemotingNet(url:String = null)
        {
            super(url);
            _needConned = false;
        }

        public static function getInstance():RemotingNet
        {
            if (_instance == null)
                _instance = new RemotingNet();

            return _instance as RemotingNet;
        }

        public override function connect(url:String = "", ... parameters):void
        {
            var f:Function = super.connect;
            parameters.unshift(url);
            f.apply(this, parameters);
        }

        public override function call(method:String, resultFunction:Function = null, failedFunction:Function = null, ... parameters):void
        {
            var f:Function = super.call;
            var path:String = SERVER_NAME + "." + method.toString();
            parameters.unshift(path, resultFunction, failedFunction);
            f.apply(this, parameters);
        }
    }
}